<?php
	
autoLoader();

// display( $_REQUEST );
// display( $_POST ); exit;

if( false == isset( $_POST['Submit'] ) || false == valStr( $_POST['first_name'] ) ) { 
	$str = '';
	$str .= '<form name=myform method=post action=modules.php?file=doctors&mid=' . $_REQUEST['mid'] . '&smid=' . $_REQUEST['smid'] . '>';
	$str .= '<script language=JavaScript>document.myform.submit();</script></form>';
	echo $str;
	exit;
}

if( true == isset( $_POST['operation'] ) && 'insert' == strtolower( $_POST['operation'] ) ) {
	
	$objBaseDoctor = new BaseDoctors();
	
	$objBaseDoctor->setDepartmentId( $_POST['department_id'] );
	$objBaseDoctor->setSpecilizationId( $_POST['specilization_id'] );
	$objBaseDoctor->setFirstName( $_POST['first_name'] );
	$objBaseDoctor->setMiddleName( $_POST['middle_name'] );
	$objBaseDoctor->setLastName( $_POST['last_name'] );
	$objBaseDoctor->setMobileNumber( $_POST['phone_number'] );
	$objBaseDoctor->setPhoneNumber( $_POST['mobile_number'] );
	$objBaseDoctor->setOfficeNumber( $_POST['office_number'] );
	$objBaseDoctor->setSpecilizationDetails( $_POST['specilization_details'] );
	$objBaseDoctor->setListOfDgress( $_POST['list_of_dgress'] );
	$objBaseDoctor->setIsVisitor( $_POST['is_visitor'] );
	$objBaseDoctor->setVisitHospitalName( $_POST['visit_hospital_name'] );
	$objBaseDoctor->setVisitDayName( $_POST['visit_day_name'] );
	$objBaseDoctor->setVisitingCharges( $_POST['visiting_charges'] );
	$objBaseDoctor->setWardId( $_POST['ward_id'] );
	$objBaseDoctor->setOfficeDetails( $_POST['office_details'] );
	$objBaseDoctor->setRoomNumber( $_POST['room_number'] );
	$objBaseDoctor->setCreatedBy( ( true == isset( $_SESSION['SESS_MEMBER_ID'] ) ) ? $_SESSION['SESS_MEMBER_ID'] : 1 );
	$objBaseDoctor->setUpdatedBy( ( true == isset( $_SESSION['SESS_MEMBER_ID'] ) ) ? $_SESSION['SESS_MEMBER_ID'] : 1 );
	$objBaseDoctor->setUpdatedOn( 'now()' );
	
	if( 1 == $objBaseDoctor->insert() ) {
		$str = '';
		$str .= '<form name=myform method=post action=modules.php?file=view_doctors&type=view&mid=' . $_REQUEST['mid'] . '&smid=' . $_REQUEST['smid'] . '>';
		$str .= '<script language=JavaScript>document.myform.submit();</script></form>';
		echo $str;
		exit;
	}
} else if( true == isset( $_POST['operation'] ) && 'update' == strtolower( $_POST['operation'] ) ) {
	$objDoctors 	= new Doctors();
	$objBaseDoctor 	= $objDoctors->fetchDoctorsById( $_POST['doctor_id'] );
	
	$objBaseDoctor->setDepartmentId( $_POST['department_id'] );
	$objBaseDoctor->setSpecilizationId( $_POST['specilization_id'] );
	$objBaseDoctor->setFirstName( $_POST['first_name'] );
	$objBaseDoctor->setMiddleName( $_POST['middle_name'] );
	$objBaseDoctor->setLastName( $_POST['last_name'] );
	$objBaseDoctor->setMobileNumber( $_POST['phone_number'] );
	$objBaseDoctor->setPhoneNumber( $_POST['mobile_number'] );
	$objBaseDoctor->setOfficeNumber( $_POST['office_number'] );
	$objBaseDoctor->setSpecilizationDetails( $_POST['specilization_details'] );
	$objBaseDoctor->setListOfDgress( $_POST['list_of_dgress'] );
	$objBaseDoctor->setIsVisitor( $_POST['is_visitor'] );
	$objBaseDoctor->setVisitHospitalName( $_POST['visit_hospital_name'] );
	$objBaseDoctor->setVisitDayName( $_POST['visit_day_name'] );
	$objBaseDoctor->setVisitingCharges( $_POST['visiting_charges'] );
	$objBaseDoctor->setWardId( $_POST['ward_id'] );
	$objBaseDoctor->setOfficeDetails( $_POST['office_details'] );
	$objBaseDoctor->setRoomNumber( $_POST['room_number'] );
	$objBaseDoctor->setCreatedBy( ( true == isset( $_SESSION['SESS_MEMBER_ID'] ) ) ? $_SESSION['SESS_MEMBER_ID'] : 1 );
	$objBaseDoctor->setUpdatedBy( ( true == isset( $_SESSION['SESS_MEMBER_ID'] ) ) ? $_SESSION['SESS_MEMBER_ID'] : 1 );
	$objBaseDoctor->setUpdatedOn( 'now()' );
	
	if( 1 == $objBaseDoctor->update() ) {
		$str = '';
		$str .= '<form name=myform method=post action=modules.php?file=view_doctors&type=view&mid=' . $_REQUEST['mid'] . '&smid=' . $_REQUEST['smid'] . '>';
		$str .= '<script language=JavaScript>document.myform.submit();</script></form>';
		echo $str;
		exit;
	}
}

?>